#ifndef SAVINGS_ACCOUNT_H
#define SAVINGS_ACCOUNT_H

#include "BankAccount.h"
#include <string>

namespace MiniBanking
{
    class CheckingAccount;
}

namespace MiniBanking
{

    /**
     * @brief Represents a Savings Account.
     *
     * Inherits from BankAccount and implements specific rules for savings accounts:
     * - Cannot deposit or withdraw directly.
     * - Can only transfer *to* the owner's CheckingAccount.
     */
    class SavingsAccount : public BankAccount
    {
    public:
        /**
         * @brief Constructs a new SavingsAccount object.
         * @param accountID The unique ID for the account.
         * @param ownerName The name of the account holder.
         * @param initialBalance The starting balance (defaults to 0.0).
         */
        SavingsAccount(const std::string &accountID, const std::string &ownerName, double initialBalance = 0.0);

        // Override virtual functions from BankAccount
        virtual ~SavingsAccount() override = default; // Use override keyword

        /**
         * @brief Gets the account type ("Savings Account").
         * @return "Savings Account" string.
         */
        virtual std::string getAccountType() const override;

        /**
         * @brief Checks if a transfer to the destination account is allowed.
         * Savings accounts can only transfer to the same owner's Checking account.
         * @param destination The target account of the transfer.
         * @return True if the transfer is permitted by rules, false otherwise.
         */
        virtual bool canTransferTo(const BankAccount &destination) const override;

        // Savings accounts do not support direct deposit or withdrawal.
        // The base class default implementations already return false.
        // We can explicitly override them to return false for clarity or rely on the base.
        // virtual bool deposit(double amount) override; // Optional: Explicit override
        // virtual bool withdraw(double amount) override; // Optional: Explicit override

        // Note: No need to override initiateTransferOut if the base class logic
        // (just decreasing balance) is sufficient, and the rule check (canTransferTo)
        // is performed before calling it by the BankSystem.

        // Default copy/move constructors/assignments are fine
        SavingsAccount(const SavingsAccount &) = default;
        SavingsAccount &operator=(const SavingsAccount &) = default;
        SavingsAccount(SavingsAccount &&) = default;
        SavingsAccount &operator=(SavingsAccount &&) = default;
    };

}

#endif
